package edu.bupt.e1btree;

public class T45BinaryTreeMaximumPathSum {
    public int maxPathSum(TreeNode root) {
        if (null == root){
            return 0;
        }
        int left = 0;
        if (null != root.left){
            left = maxPathSum(root.left);
        }
        int right = 0;
        if (null != root.right){
            right = maxPathSum(root.right);
        }

        return root.val + Math.max(left,right);

    }
}
